package dongshi.daddy.main;

import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import dongshi.daddy.myexternalconfig.MyExternalConfigConsumerConfiguration;
import dongshi.daddy.myexternalconfig.MyExternalConfigConusmerService;
import dongshi.daddy.service.externalconfig.MyExternalConfigService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.io.IOException;

public class MyConsumerWithExternalConfigMain {
    public static void main(String[] args) throws IOException {
        AnnotationConfigApplicationContext ac
                = new AnnotationConfigApplicationContext(MyExternalConfigConsumerConfiguration.class);
        System.out.println("ApplicationConfig is: " + ac.getBean(ApplicationConfig.class));
        System.out.println("RegistryConfig is: " + ac.getBean(RegistryConfig.class));
        MyExternalConfigConusmerService myExternalConfigConusmerService
                = ac.getBean("myExternalConfigConusmerService", MyExternalConfigConusmerService.class);
        MyExternalConfigService myExternalConfigService = myExternalConfigConusmerService.returnClassProviderService();
        System.out.println(myExternalConfigService.sayHi("why me!!!"));
    }
}
